const order = ['index','index']
import {voteModel} from "../../../model/vote"
import {config} from "../../../config"
var vote = new voteModel()
var i 
Page({
  /**
   * 页面的初始数据
   */
  data: {
    toView:'',
    tuibian_detail:[
    {
    id:"24",
    course_name:"《智慧女性》研修班",
    daoshi_image:"https://sijie-1301278475.cos.ap-shanghai.myqcloud.com/mini-sijie/teacher1.png",
    daoshi_name:"王学平",
    daoshi_jieshao:"个人成长导师\n企业成长研究专家",
    course_xinxi:"期数：共10期\n费用：1980元/期",
    BM_text:"我要报名>",
    },
    {
    id:"28",
    course_name:"4VS国际形体训练营",
    daoshi_image:"https://sijie-1301278475.cos.ap-shanghai.myqcloud.com/mini-sijie/teacher2.png",
    daoshi_name:"邱兵",
    daoshi_jieshao:"著名时尚导演\n4VS时尚创始人",
    course_xinxi:"时间：2021年1月6-8日\n费用：19800元（三天）",
    BM_text:"我要报名>",
    }
    ],
    swiper_image:[],
    player:[],
    ruleDesImageUrl:'/static/Bitmap.png',
    ruleDesImageHidden:true,
    Toast:true
  },
  /**
   * 活动规则
   */
  ruleAction:function(){
    console.log()
    var that = this;
    that.setData({
      ruleDesImageHidden: false,
    })
    setTimeout(function(){
      that.setData({
        ruleDesImageHidden: true,
      })
    },3000)
 },
  getList(){
    vote.list().then(
      res=>{
        console.log(res)
        this.setData({
          player:res.data.records
        })
      }
    )
  },
  jqqd(){
    wx.showToast({
      title:"尽请期待",        
      icon:'none',         
      duration: 2000         
    }) 
  },
  /**
   * 点击跳转 
   */
  toActivity:function(e){
    var data = e.currentTarget.dataset
    console.log(data)
      wx.navigateTo({
        url: '/pages/action/detail/detail?id='+data.id,
      })     
  },
  /**
   * 点击查看图片
   */
  actionDetail(e){
    console.log(e)
      wx.previewImage({
      urls: e.currentTarget.dataset.list,
      current:e.currentTarget.dataset.url
    })
  },
  appTitbits(){
    vote.appTitbits().then(
      res=>{
        this.setData({
          swiper_image:res.data,
        })
      }
    )
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.url){
      let url = decodeURIComponent(options.url);
      wx.navigateTo({
        url
      })
    }
    if(options.scene){
      let scene = decodeURIComponent(options.scene);
      wx.navigateTo({
        url: '/pages/vote/detail/detail?id=' + scene.split(";;")[0],
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    this.getList()
    this.appTitbits()
    i = setInterval(function(){
      that.getList()
    },30000)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    clearInterval(i)
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    clearInterval(i)
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  methods:{
  /**
   * 风尚评选滑动
   */
  onShareAppMessage: function () {  
  },
  upper(e) {
    console.log(e)
  },
  lower(e) {
    console.log(e)
  },
  scroll(e) {
    console.log(e)
  },
  scrollToTop() {
    this.setAction({
      scrollTop: 0
    })
  },
  tap() {
    for (let i = 0; i < order.length; ++i) {
      if (order[i] === this.data.toView) {
        this.setData({
          toView: order[i + 1],
          scrollTop: (i + 1) * 200
        })
        break
      }
    }
  },
  tapMove() {
    this.setData({
      scrollTop: this.data.scrollTop + 10
    })
  },
  /**
   * 观看直播（未开发）
   */
  tozhibo:function(){
    wx.showModal({
      title: '提示',
      content: '此功能暂未开发',
      success: function(res) {
       if (res.confirm) {
        console.log('用户点击确定')
       }
      }
     })
  }
} 
})
